package com.tangchao.client.sdh.sdhinterface
{
	import com.tangchao.client.sdh.control.SanDaHaControl;
	import com.tangchao.client.sdh.definition.DFCardColor;
	import com.tangchao.client.sdh.event.JiaoFenEvent;

	//此类为主动接口
	public class Out
	{
		static private var _instance:Out;
		
		public function Out()
		{
			_instance = this;
		}
		
		static public function getInstance():Out
		{
			if(!_instance)
			{
				_instance = new Out;
			}
			
			return _instance;
		}
		
		//主动接口 登录
		public function onLoginGame(userName:String, pass:String):void
		{
			SanDaHaControl.getInstance().setMsg("登录 "+userName+" "+pass);
		}
		
		/*
		*主动接口，通知前台逻辑用户点击准备按钮
		*/
		public function onReady():void
		{
			SanDaHaControl.getInstance().setMsg("已准备");
		}
		
		//
		public function onSetScoreMode(isApprove:Boolean, model:int, difen:int):void
		{
			SanDaHaControl.getInstance().setMsg("onSetScoreMode:"+model.toString()+" "+difen.toString());
			if(isApprove)
			{
				SanDaHaControl.getInstance().setMsg("");
			}
			else
			{
				SanDaHaControl.getInstance().setMsg("开始"+model.toString()+" 底分:"+difen.toString());
			}
		}
		
		public function onBet(isBet:Boolean, val:int=0):void
		{
			if(isBet)
			{
				SanDaHaControl.getInstance().setMsg("叫分："+val.toString());
			}
			else
			{
				SanDaHaControl.getInstance().setMsg("不叫分");
			}
		}
		
		public function onClickCard(cardArr:Array, isPlay:Boolean):void
		{
			var msg:String;
			var i:int;
			
			if(cardArr)
			{
				if(isPlay && cardArr)
				{
					msg = "选牌:";
				}
				else
				{
					msg = "取消选牌:";
				}
				
				for(i=0; i<cardArr.length; i++)
				{
					msg += cardArr[i].toString()+" ";
				}
				SanDaHaControl.getInstance().setMsg(msg);
			}	
		}
		
		//0-不叫 1-方片 2-红桃 3-草花 4-黑桃
		public function onClaimMianCard(i:int):void
		{
			var msg:String;
			
			switch(i)
			{
				case DFCardColor.COLOR_NONE:
					SanDaHaControl.getInstance().setMsg("未选择花色");	
					break;
				case DFCardColor.COLOR_FANGKUAI:
					SanDaHaControl.getInstance().setMsg("选择花色:方块");	
					break;
				case DFCardColor.COLOR_HEITAO:
					SanDaHaControl.getInstance().setMsg("选择花色:黑桃");	
					break;
				case DFCardColor.COLOR_HONGTAO:
					SanDaHaControl.getInstance().setMsg("选择花色:红桃");	
					break;
				case DFCardColor.COLOR_CAOHUA:
					SanDaHaControl.getInstance().setMsg("选择花色:草花");	
					break;
				default:
					break;
			}
		}
		
		public function onPutBottomCard(cardArr:Array):void
		{
			var i:int;
			var msg:String;
			
			for(i=0; i<cardArr.length; i++)
			{
				msg += cardArr[i].toString()+" ";
			}
			SanDaHaControl.getInstance().setMsg("埋底牌:"+msg);
		}
		
		public function onPlayCars(cardArr:Array):void
		{
			SanDaHaControl.getInstance().setMsg("出牌"+cardArr.toString());
		}
		
		public function onDao():void
		{
			SanDaHaControl.getInstance().setMsg("倒");
		}
		
		public function onGen():void
		{
			SanDaHaControl.getInstance().setMsg("跟");
		}
		
		public function onFan():void
		{
			SanDaHaControl.getInstance().setMsg("反");
		}
		
		public function onSurrender():void
		{
			SanDaHaControl.getInstance().setMsg("投降");
		}
		
		public function onVerifyScores():void
		{
			SanDaHaControl.getInstance().setMsg("结算确定");
		}
		
		public function onTuoGuan(isTuoGuan:Boolean):void
		{
			if(isTuoGuan)
			{
				SanDaHaControl.getInstance().setMsg("托管");
			}
			else
			{
				SanDaHaControl.getInstance().setMsg("取消托管");
			}
		}
		
		public function onUseMaigic(id:String):void
		{
			SanDaHaControl.getInstance().setMsg("使用道具:"+id);
		}
		
		public function onApprovalJoining(apply:Boolean, userName:String):void
		{
			if(apply)
			{
				SanDaHaControl.getInstance().setMsg("批准用户加入:"+userName);
			}
			else
			{
				SanDaHaControl.getInstance().setMsg("拒绝用户加入:"+userName);
			}
		}
		
		public function onInviteUser(userName:String):void
		{
			SanDaHaControl.getInstance().setMsg("邀请用户加入:"+userName);
		}
		
		//时间到 自动出牌 cardArr选择的牌
		public function doAotuOut(cardArr:Array):void
		{
			if(cardArr)
			{
				SanDaHaControl.getInstance().setMsg("自动出牌:"+cardArr.toString());
			}
		}
	}
}